#!/bin/bash

# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo -e "${YELLOW}开始执行测试...${NC}"

# 运行所有测试
mvn clean test

# 检查测试结果
if [ $? -eq 0 ]; then
  echo -e "${GREEN}所有测试通过!${NC}"
else
  echo -e "${RED}测试失败，请检查日志获取详细信息${NC}"
fi

# 运行特定的测试套件
run_test_suite() {
  echo -e "${YELLOW}运行测试套件: $1${NC}"
  mvn test -Dtest=$1
}

# 根据参数运行特定测试
if [ "$1" == "recommender" ]; then
  run_test_suite "RecommenderSystemTestSuite"
elif [ "$1" == "scoring" ]; then
  run_test_suite "ScoringSystemTestSuite"
elif [ "$1" == "integration" ]; then
  mvn test -Dtest="*IntegrationTest"
elif [ "$1" == "unit" ]; then
  run_test_suite "UnitTestSuite"
elif [ "$1" == "mocks" ]; then
  mvn test -Dtest="*MockTest"
fi

echo -e "${YELLOW}测试执行完成${NC}" 